package com.huawei.appmarket.service.usercenter.userinfo.view.widget;

import android.content.Context;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.huawei.appmarket.service.usercenter.userinfo.bean.CountryInfo;
import com.huawei.appmarket.service.usercenter.userinfo.bean.UserInfoBean;
import huawei.widget.HwButton;
import huawei.widget.HwEditText;
import java.util.List;
import o.azb;
import o.der.d;
import o.der.f;
import o.der.g;
import o.dof;
import o.emj;
import o.emn;
import o.eqp;

public class MobilePhoneChangeViewOverSea extends MobilePhoneChangeView {
    private List<CountryInfo> ʻ;
    private TextView ʼ;
    private RelativeLayout ॱॱ;

    public MobilePhoneChangeViewOverSea(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public MobilePhoneChangeViewOverSea(Context context) {
        super(context);
    }

    public void setInterfaceAndUserInfo(emn o_emn, UserInfoBean userInfoBean) {
        this.ᐝ = o_emn;
        this.ʽ = userInfoBean;
        if (this.ˎ != null) {
            this.ˎ.setFilters(new InputFilter[]{new LengthFilter(50)});
            this.ˎ.setInputType(3);
            if (!(this.ʽ == null || dof.ˋ(this.ʽ.ॱ()))) {
                this.ˎ.setText(ˋ(this.ʽ.ॱ()));
                new emj(50).ॱ(this.ˎ, this.ˎ.getText().toString());
            }
        }
        ॱॱ();
    }

    private void ॱॱ() {
        if (this.ʽ != null) {
            String ʻ = this.ʽ.ʻ();
            String str = "";
            str = "";
            str = "";
            str = "";
            if (dof.ˋ(ʻ)) {
                ʻ = eqp.ॱ();
                if (this.ʻ != null && !dof.ˋ(ʻ)) {
                    str = ReceiverInfoAddViewOverSea.ˏ(ʻ, this.ʻ);
                    if (!dof.ˋ(str)) {
                        this.ʽ.ᐝ(str);
                        this.ʼ.setText(eqp.ˊ(ʻ) + "  +" + str);
                        return;
                    }
                    return;
                }
                return;
            }
            str = ReceiverInfoAddViewOverSea.ॱ(ʻ, this.ʻ);
            if (!dof.ˋ(str)) {
                this.ʼ.setText(eqp.ˊ(str) + "  +" + ʻ);
            }
        }
    }

    protected void ˊ() {
        View inflate = LayoutInflater.from(this.ˋ).inflate(g.ᶥ, this);
        this.ˎ = (HwEditText) inflate.findViewById(d.ᵔ);
        this.ʼ = (TextView) inflate.findViewById(d.ˋʾ);
        this.ॱॱ = (RelativeLayout) inflate.findViewById(d.ˊꞌ);
        azb.ʻ(this.ˎ);
        azb.ˎ(inflate, d.ʻˊ);
        azb.ॱ(inflate, d.ʽˋ);
        azb.ॱ(inflate, d.ˊꞌ);
        azb.ˋ((TextView) inflate.findViewById(d.ꜞ));
        this.ॱ = (HwButton) inflate.findViewById(d.ᐝˋ);
        ॱ();
        ˊॱ();
    }

    protected void ॱ() {
        this.ॱ.setEnabled(true);
        this.ॱ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ MobilePhoneChangeViewOverSea ˊ;

            {
                this.ˊ = r1;
            }

            public void onClick(View view) {
                if (view == this.ˊ.ॱ) {
                    boolean ˊ = this.ˊ.ʽ();
                    if (this.ˊ.ʽ == null) {
                        Toast.makeText(this.ˊ.ˋ, f.ᐝʼ, 0).show();
                    } else if (ˊ && this.ˊ.ᐝ != null) {
                        this.ˊ.ᐝ.ˎ(this.ˊ.ʽ);
                    }
                }
            }
        });
    }

    public void setCountryInfoList(List<CountryInfo> list) {
        this.ʻ = list;
    }

    private boolean ʽ() {
        if (this.ʽ == null) {
            this.ʽ = new UserInfoBean();
        }
        return ᐝ() && ʼ();
    }

    private boolean ᐝ() {
        String charSequence = this.ʼ.getText().toString();
        if (dof.ˋ(charSequence)) {
            Toast.makeText(this.ˋ, f.ˆ, 0).show();
            return false;
        }
        this.ʽ.ᐝ(ˎ(charSequence));
        return true;
    }

    private boolean ʼ() {
        String ॱˊ = ॱˊ();
        boolean z = !dof.ˋ(ॱˊ) && ॱˊ.length() <= 50 && ॱˊ.length() >= 4 && emj.ˋ(ॱˊ);
        if (z) {
            this.ʽ.ˊ(ॱˊ);
            return true;
        }
        Toast.makeText(this.ˋ, this.ˋ.getResources().getString(f.ˉˋ), 0).show();
        return false;
    }

    private String ॱˊ() {
        if (ˋ()) {
            return this.ˎ.getText().toString();
        }
        return this.ʽ.ॱ();
    }

    private void ˊॱ() {
        this.ॱॱ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ MobilePhoneChangeViewOverSea ˊ;

            {
                this.ˊ = r1;
            }

            public void onClick(View view) {
                if (view == this.ˊ.ॱॱ) {
                    this.ˊ.ॱॱ.setFocusableInTouchMode(true);
                    this.ˊ.ॱॱ.setFocusable(true);
                    this.ˊ.ॱॱ.requestFocus();
                    if (this.ˊ.ᐝ != null) {
                        this.ˊ.ᐝ.aq_();
                    }
                }
            }
        });
    }

    public void setCountryPhone(String str) {
        this.ʼ.setText(str);
    }

    public String ˎ() {
        return this.ʼ.getText().toString();
    }

    protected String ˋ(String str) {
        return emj.ˏ(str);
    }

    public boolean ʻ() {
        String str;
        if (this.ʽ == null) {
            str = "";
        } else {
            str = this.ʽ.ʻ();
        }
        return ॱ(str) || ˋ();
    }

    private boolean ॱ(String str) {
        return !str.equals(ˎ(this.ʼ.getText().toString()));
    }

    private String ˎ(String str) {
        String[] split = str.split("\\+");
        return split[split.length - 1];
    }
}
